load("//bazel:skia_rules.bzl", "exports_files_legacy", "generate_cpp_files_for_headers", "skia_cc_deps", "skia_cc_library", "skia_filegroup", "split_srcs_and_hdrs")

package(
    default_applicable_licenses = ["//:license"],
)

licenses(["notice"])

exports_files_legacy()

VK_FILES = [
    "VulkanExtensions.cpp",
    "VulkanInterface.cpp",
    "VulkanInterface.h",
    "VulkanMemory.cpp",
    "VulkanMemory.h",
    "VulkanUtilsPriv.cpp",
    "VulkanUtilsPriv.h",
    "VulkanMutableTextureStatePriv.h",
    "VulkanMutableTextureState.cpp",
]

split_srcs_and_hdrs(
    name = "_vk",
    files = VK_FILES,
)

skia_filegroup(
    name = "srcs",
    srcs = [
        ":_vk_srcs",
        "//src/gpu/vk/vulkanmemoryallocator:vma_srcs",
    ],
    visibility = [
        "//src/gpu:__pkg__",
    ],
)

skia_filegroup(
    name = "private_hdrs",
    srcs = [
        ":_vk_hdrs",
        "//src/gpu/vk/vulkanmemoryallocator:vma_hdrs",
    ],
    visibility = [
        "//src/gpu:__pkg__",
        "//src/gpu/ganesh/vk:__pkg__",
    ],
)

skia_cc_deps(
    name = "deps",
    visibility = ["//src/gpu:__pkg__"],
    deps = select({
        "//src/gpu:vulkan_with_vma": ["//third_party/vulkanmemoryallocator"],
        "//conditions:default": [],
    }),
)

generate_cpp_files_for_headers(
    name = "headers_to_compile",
    headers = [
        "VulkanMutableTextureStatePriv.h",
    ],
)

skia_cc_library(
    name = "vk",
    srcs = [
        ":_vk_srcs",
        "//include/private/gpu/vk:private_hdrs",
    ],
    hdrs = [
        ":_vk_hdrs",
        "//include/gpu/vk:public_hdrs",
    ],
    defines = [
        "SK_USE_EXTERNAL_VULKAN_HEADERS",
    ],
    features = ["layering_check"],
    visibility = [
        "//src/gpu/ganesh/vk:__pkg__",
        "//src/gpu/vk/vulkanmemoryallocator:__pkg__",
    ],
    deps = [
        "//:core",
        "//include/third_party/vulkan",
        "//src/base",
        "//src/gpu",
        "//src/sksl/codegen:spirv",
    ],
)
